home *** CD-ROM | disk | FTP | other *** search
- unit HandleTheMenus;
-
- {File name : HandleTheMenus.Pas }
- {Function: Handle all menu selections.}
- { This procedure is called when a menu item is selected.}
- { There is one CASE statement for all Lists. There is}
- { another CASE for all the commands in each List.}
- {History: 10/6/89 Original by Prototyper. }
- { }
-
- interface
-
- uses
- Dialog_2, Dialog_1, Globals, InitTheMenus, Utilities, MenuUtilities;
-
- procedure Handle_My_Menu (var doneFlag: boolean; theMenu, theItem: integer; var theInput: TEHandle);{Handle menu selection}
-
- implementation
-
- procedure Handle_My_Menu; {Handle menu selections realtime}
- const
- L_Apple = 1001; {Menu list}
- C_About = 1;
- L_File = 1002; {Menu list}
- C_Open = 1;
- C_Close = 3;
- C_Save = 4;
- C_Save_As = 5;
- C_Page_Setup = 7;
- C_Print = 8;
- C_Quit = 10;
- L_Edit = 1003; {Menu list}
- C_Cut = 1;
- C_Copy = 2;
- C_Paste = 3;
- C_Clear = 4;
- L_Shapes = 1004; {Menu list}
- C_Rectangle = 1;
- C_Square = 2;
- C_Circle = 3;
- C_Triangle = 4;
- var
- DNA: integer; {For opening DAs}
- BoolHolder: boolean; {For SystemEdit result}
- DAName: Str255; {For getting DA name}
- SavePort: GrafPtr; {Save current port when opening DAs}
-
- begin {Start of procedure}
-
- case theMenu of {Do selected menu list}
-
- L_Apple:
- begin
- case theItem of{Handle all commands in this menu list}
- C_About:
- begin
- D_Dialog_2;{Call a dialog for this menu selection}
- ResetWindow;
- end;
- otherwise {Handle the DAs}
- begin {Start of Otherwise}
- GetPort(SavePort);{Save the current port}
- GetItem(AppleMenu, theItem, DAName);{Get the name of the DA selected}
- EnableItem(M_File, 1);
- EnableItem(M_File, 3);
- EnableItem(M_File, 4);
- EnableItem(M_File, 5);
- EnableItem(M_File, 7);
- EnableItem(M_File, 8);
- EnableItem(M_Edit, 1);
- EnableItem(M_Edit, 2);
- EnableItem(M_Edit, 3);
- EnableItem(M_Edit, 4);
- NotInDA := false;
- DNA := OpenDeskAcc(DAName);{Open the DA selected}
- SetPort(SavePort);{Restore to the saved port}
- end; {End of Otherwise}
-
- end; {End of item case}
- end; {End for this list}
-
- L_File:
- begin
- case theItem of{Handle all commands in this menu list}
- C_Open:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Close:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Save:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Save_As:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Page_Setup:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Print:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Quit:
- begin
- doneFlag := TRUE;
- end;
- otherwise
- begin {Start of the Otherwise}
- end; {End of Otherwise}
-
- end; {End of item case}
- end; {End for this list}
-
- L_Edit:
- begin
- BoolHolder := SystemEdit(theItem - 1);{Let the DA do the edit to itself}
- if not (BoolHolder) then{If not a DA then we get it}
- begin {Handle by using a Case statment}
- case theItem of{Handle all commands in this menu list}
- C_Cut:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Copy:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Paste:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Clear:
- begin
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- otherwise{Send to a DA}
- begin {Start of the Otherwise}
- end; {End of Otherwise}
-
- end; {End of not BoolHolder}
- end; {End of item case}
- end; {End for this list}
-
- L_Shapes:
- begin
- case theItem of{Handle all commands in this menu list}
- C_Rectangle:
- begin
- UncheckMenus;
- CheckItem(M_Shapes, 1, true);
- WhichShape := Rectangle;
- DrawShapes(Rectangle);
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Square:
- begin
- UncheckMenus;
- CheckItem(M_Shapes, 2, true);
- WhichShape := Square;
- DrawShapes(Square);
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Circle:
- begin
- UncheckMenus;
- CheckItem(M_Shapes, 3, true);
- WhichShape := Circle;
- DrawShapes(Circle);
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- C_Triangle:
- begin
- UncheckMenus;
- CheckItem(M_Shapes, 4, true);
- WhichShape := Triangle;
- DrawShapes(Triangle);
- {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
- end;
- otherwise
- begin {Start of the Otherwise}
- end; {End of Otherwise}
-
- end; {End of item case}
- end; {End for this list}
-
- otherwise
- begin {Start of the Otherwise}
- end; {End of Otherwise}
-
- end; {End for the Lists}
-
- HiliteMenu(0); {Turn menu selection off}
- end; {End of procedure Handle_My_Menu}
-
- end. {End of unit}